# -*- coding:utf-8

# 5169. 日期之间隔几天 显示英文描述
# 用户通过次数51
# 用户尝试次数64
# 通过次数51
# 提交次数73
# 题目难度Easy
# 请你编写一个程序来计算两个日期之间隔了多少天。
#
# 日期以字符串形式给出，格式为 YYYY-MM-DD，如示例所示。

class Solution:
    def daysBetweenDates(self, date1: str, date2: str) -> int:



        def isrunnian(year):
            if year%400 == 0 :
                return True
            if year%100 == 0 :
                return False
            if year%4 == 0 :
                return True
            return False

        mmm = [0,31,28,31,30,31,30,31,31,30,31,30,31]

        def dijitian(year,month,day):
            dayss = 0
            for i in range(1970,year):
                if isrunnian(i):
                    dayss += 366
                else:
                    dayss += 365
            print(year," ",dayss)
            for m in range(1,month):
                dayss+= mmm[m]
            print(year," ",dayss)

            if month>=3 and isrunnian(year):
                dayss += 1

            dayss += day
            print(year," ",dayss)
            return dayss

        d1 = date1.split("-")
        di1 = dijitian(int(d1[0]),int(d1[1]),int(d1[2]))

        d2 = date2.split("-")
        di2 = dijitian(int(d2[0]),int(d2[1]),int(d2[2]))

        return abs(di2-di1)

res = Solution().daysBetweenDates(date1 = "2020-01-15", date2 = "2019-12-31")
print(res)
